package com.xs.designpattern;

import lombok.extern.slf4j.Slf4j;

/**
 * @author xs
 */
@Slf4j
public class Main {
    private static final Kingdom KINGDOM = new Kingdom();

    public static void main(String[] args) {
        log.info("创建精灵王国开始！");
        createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
        log.info(KINGDOM.getArmy().getDescription());
        log.info(KINGDOM.getCastle().getDescription());
        log.info(KINGDOM.getKing().getDescription());
        log.info("创建精灵王国开始！");
        log.info("创建兽人王国结束！");
        createKingdom(Kingdom.FactoryMaker.KingdomType.ORC);
        log.info(KINGDOM.getArmy().getDescription());
        log.info(KINGDOM.getCastle().getDescription());
        log.info(KINGDOM.getKing().getDescription());
        log.info("创建兽人王国结束！");

    }

    /**
     * 创建王国。
     *
     * @param kingdomType type of Kingdom
     */
    public static void createKingdom(final Kingdom.FactoryMaker.KingdomType kingdomType) {
        final KingdomFactory kingdomFactory = Kingdom.FactoryMaker.makeFactory(kingdomType);
        KINGDOM.setKing(kingdomFactory.createKing());
        KINGDOM.setCastle(kingdomFactory.createCastle());
        KINGDOM.setArmy(kingdomFactory.createArmy());
    }
}